#! /bin/sh

export JAVA_HOME="/usr/java/jdk1.8.0_20"
export MAVEN_HOME="/work/resources/apache-maven-3.3.3"
export PATH=$PATH:$MAVEN_HOME/bin:$JAVA_HOME/bin
echo '基本环境变量配置成功...'

code=/work/resources/pay #源码
workspace=/work/tomcat/app
echo '正在切换代码目录'${code}
cd ${code}

echo '正在拉取最新代码...'
git pull origin master

echo '正在编译...'
mvn clean 
mvn package -Dmaven.test.skip=true

echo '切换至工作目录'${workspace}
cd ${workspace}

echo '准备停止Tomcat'
sh tomcat.sh stop

echo '清空Tomcat webapps...'
rm -rf ./webapps/*

echo '拷贝源码至工作目录...'
cp ${code}/target/*.war ./webapps

echo '准备启动tomcat...'
sh tomcat.sh start
